#ifndef JOYSTICK_H
#define JOYSTICK_H

#include "UserControlledInputDevice.h"

#define JOYSTICK_SMOOTH_SIZE (5)

/*
 * Class to handle joystick input in the game
 */
class Joystick : public UserControlledInputDevice, public OIS::JoyStickListener
{
public:
    Joystick(OIS::JoyStick *k);
    ~Joystick() {}
    
    Ogre::Radian getX();
    Ogre::Radian getY();
    void destroy(OIS::InputManager *i_m) { i_m->destroyInputObject(joystick); }
    void capture() { joystick->capture(); }
    bool isResettable() { return false; }
    void initialise();
    
    bool buttonPressed(const OIS::JoyStickEvent &, int);
    bool buttonReleased(const OIS::JoyStickEvent &, int);
    bool axisMoved(const OIS::JoyStickEvent &, int);
    
    bool next();
    bool previous();
    bool quit();
    bool triggerPressed();
    
private:
    OIS::JoyStick *joystick;
    int x[JOYSTICK_SMOOTH_SIZE], y[JOYSTICK_SMOOTH_SIZE], x_index, y_index;
    float x_mean, y_mean;
    
    bool trigger_down, go_next, go_previous, quit_pressed;
    int previous_X_pos, previous_Y_pos;
} ;

#endif
